﻿using LogDashboard.Application.Model;
using LogDashboard.Application.Services;
using Microsoft.AspNetCore.Mvc;

namespace LogDashboard.WebAPI.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class DashboardController : ControllerBase
    {
        private readonly LogParseService logParseService = new();

        [HttpPost]
        public ActionResult ParseData(IFormFile file)
        {
            logParseService.ParseLog(file.OpenReadStream());
            return Ok();
        }

        [HttpGet]
        public ActionResult<List<CacheDataModel>> GetCacheLogs()
        {
            return Ok(LogParseService.cacheDataModels);
        }

        [HttpGet]
        public ActionResult<Dictionary<string, Dictionary<DateTime, int>>> GetCacheLineChartData()
        {
            return Ok(LogParseService.CacheLineChartData);
        }

        [HttpGet]
        public ActionResult<List<UowDataModel>> GetUowLogs()
        {
            return Ok(LogParseService.uowDataModels);
        }
    }
}
